package com.easydict.core;

import com.easydict.writer.EnhancedDictionaryPropertyWriter;
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;

/**
 * 默认写入器创建策略实现
 * 使用增强的字典属性写入器
 */
public class DefaultWriterCreationStrategy implements WriterCreationStrategy {

    private static final String STRATEGY_NAME = "DefaultDictionaryWriterCreation";
    private static final String VERSION = "2.0.0";

    private final String configuredSuffix;

    public DefaultWriterCreationStrategy() {
        this("Dict"); // 默认后缀
    }

    public DefaultWriterCreationStrategy(String configuredSuffix) {
        this.configuredSuffix = configuredSuffix;
    }

    @Override
    public BeanPropertyWriter createDictionaryWriter(WriterCreationContext context) {
        return new EnhancedDictionaryPropertyWriter(
                context.getOriginalWriter(),
                context.getAnnotation(),
                context.getResolver(),
                context.getSerializationContext(),
                configuredSuffix
        );
    }

    @Override
    public String getStrategyName() {
        return STRATEGY_NAME;
    }

    @Override
    public String getVersion() {
        return VERSION;
    }
}
